package 剑指offer;

public class p57_I和为s的两个数字 {
    public int[] twoSum(int[] nums, int target) {
        //递增数组！！！！
         int left=0;
         int right=nums.length-1;

         while (left<right) {
             int sum=nums[left]+nums[right];

             if (sum<target) {
                 left++;
             }else if(sum>target) {
                 right--;
             }else {
                 //sum == target
                 return new int[] {nums[left],nums[right]};
             }
         }
         return new int[0];
    }
}
